package com.ruoyi.project.module.ossConfigLog.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.ossConfigLog.domain.OssConfigLog;
import com.ruoyi.project.module.ossConfigLog.service.IOssConfigLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * 阿里云OSS资源更新日志 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-04-08
 */
@Controller
@RequestMapping("/module/ossConfigLog")
public class OssConfigLogController extends BaseController
{
    private String prefix = "module/ossConfigLog";
	
	@Autowired
	private IOssConfigLogService ossConfigLogService;
	
	@RequiresPermissions("module:ossConfigLog:view")
	@GetMapping()
	public String ossConfigLog()
	{
	    return prefix + "/ossConfigLog";
	}
	
	/**
	 * 查询阿里云OSS资源更新日志列表
	 */
	@RequiresPermissions("module:ossConfigLog:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(OssConfigLog ossConfigLog)
	{
		startPage();
        List<OssConfigLog> list = ossConfigLogService.selectOssConfigLogList(ossConfigLog);
		return getDataTable(list);
	}
	
	/**
	 * 新增阿里云OSS资源更新日志
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存阿里云OSS资源更新日志
	 */
	@RequiresPermissions("module:ossConfigLog:add")
	@Log(title = "阿里云OSS资源更新日志", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(OssConfigLog ossConfigLog)
	{		
		return toAjax(ossConfigLogService.insertOssConfigLog(ossConfigLog));
	}

	/**
	 * 修改阿里云OSS资源更新日志
	 */
	@GetMapping("/edit/{ossConfigLogId}")
	public String edit(@PathVariable("ossConfigLogId") Integer ossConfigLogId, ModelMap mmap)
	{
		OssConfigLog ossConfigLog = ossConfigLogService.selectOssConfigLogById(ossConfigLogId);
		mmap.put("ossConfigLog", ossConfigLog);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存阿里云OSS资源更新日志
	 */
	@RequiresPermissions("module:ossConfigLog:edit")
	@Log(title = "阿里云OSS资源更新日志", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(OssConfigLog ossConfigLog)
	{		
		return toAjax(ossConfigLogService.updateOssConfigLog(ossConfigLog));
	}
	
	/**
	 * 删除阿里云OSS资源更新日志
	 */
	@RequiresPermissions("module:ossConfigLog:remove")
	@Log(title = "阿里云OSS资源更新日志", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(ossConfigLogService.deleteOssConfigLogByIds(ids));
	}
	
}
